/*
package com.wishtree.controller;

import org.springframework.web.bind.annotation.*;
import com.wishtree.domain.entity.Wish;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Flow;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.SubmissionPublisher;

*/
/**
 * @Author parkin
 * @Date 2021/11/2 10:30
 * @Version 2.0
 * @Description
 *//*

@RestController
@RequestMapping("/wish")
public class WishController {

   */
/* @GetMapping("/list")
    public Flux<List<Wish>> list() {
        Wish wish = new Wish("我想中500万",1L);
        for (int i = 1; i<=10000; i++) {

        }
        return Flux.just(List.of(wish)).delayElements(Duration.ofMillis(100));
    }*//*


    @GetMapping("/myList")
    public Flow.Publisher<List<Wish>> myWishList() {
        Wish wish = new Wish("我想中500万",1L);
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Executor executor = (Runnable command) -> ForkJoinPool.commonPool().execute(command);
        SubmissionPublisher publisher = new SubmissionPublisher(executor,Flow.defaultBufferSize());
        publisher.submit(List.of(wish));
        return publisher;
       */
/* return JdkFlowAdapter.publisherToFlowPublisher(
                Flux.just(List.of(wish))
        );*//*

    }


    @GetMapping("/myList2")
    public List<Wish> myWishList2() {
        Wish wish = new Wish("我想中500万",1L);
        for (int i = 1; i<=10000; i++) {

        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return List.of(wish);
    }


    @PostMapping("/publishWish")
    public void publishWish(@RequestBody Wish wish) {
        System.out.println("用户"+wish.getUserId()+"发布了愿望: "+ wish.getContent());
    }
}
*/
